using AutoMapper;
using MyAutoMapper.Model;

namespace MyAutoMapper.Profile;

/// <summary>
/// 配置AutoMapper
/// </summary>
public abstract class Profile
{
    public static IMapper MapperService()
    {
        var config = new MapperConfiguration(cfg => { cfg.AddProfile(new Mapping()); });
        var mapper = config.CreateMapper();
        return mapper;
    }
}

// 添加业务对象的映射
public class Mapping : AutoMapper.Profile
{
    public Mapping()
    {
        // 映射不可逆
        CreateMap<UserDao, UserDto>(); // A => B
        CreateMap<UserDto, UserDao>(); // B => A
    }
}